library(rgeos,sp,sf)

data<-read.csv("C:/Users/u5390570/Documents/Geocron Merger.csv",stringsAsFactors=FALSE)

dists<-matrix(NA,dim(data)[1],1)

for (i in 1:dim(data)[1]){
  
  if (!is.na(data$my_lat[i])){
    
    test<-SpatialPoints((cbind(data$my_long[i],data$my_lat[i])),proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs"))
    test2<-SpatialPoints((cbind(data$Longitude[i],data$Latitude[i])),proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs"))
    
    dists[i]<-spDistsN1(test,test2,longlat=T)
    
  }}

gea_diffs<-quantile(dists,probs=seq(0,1,.1),na.rm=T)

data<-read.csv("C:/Users/u5390570/Documents/Dincecco Merger.csv",stringsAsFactors=FALSE)
dists<-matrix(NA,dim(data)[1],1)
data$cm_long<-as.numeric(data$cm_long)

for (i in 1:dim(data)[1]){
  
  if (!is.na(data$cm_lat[i])){
    
    test<-SpatialPoints((cbind(data$cm_long[i],data$cm_lat[i])),proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs"))
    test2<-SpatialPoints((cbind(data$longitude[i],data$latitude[i])),proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs"))
    
    dists[i]<-spDistsN1(test,test2,longlat=T)
    
  }}

din_diffs<-quantile(dists,probs=seq(0,1,.1),na.rm=T)

stargazer(data.frame(diffs,din_diffs),summary=F)
